'use strict'

const Koa = require('koa')
const bodyParser = require('koa-bodyparser')()
const helmet = require("koa-helmet")
const router = require('./routes/index')
const { errorHandler, responseHandler } = require('./middlewares/response')

const app = new Koa()

// Error Handler
app.use(errorHandler)

// Global Middlewares
app.use(bodyParser)

// Helmet
app.use(helmet())

// Routes
app.use(router.routes(), router.allowedMethods())

// Response
app.use(responseHandler)

module.exports = app